# Maintainer: Naveen M K <naveen521kk@gmail.com>

_pyname=pynndescent
_realname=pynndescent
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.5.8
pkgrel=1
pkgdesc='Nearest Neighbor Descent (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64')
url="https://github.com/lmcinnes/pynndescent"
license=('spdx:BSD-2-Clause')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python"
  "${MINGW_PACKAGE_PREFIX}-python-joblib"
  "${MINGW_PACKAGE_PREFIX}-python-numpy"
  "${MINGW_PACKAGE_PREFIX}-python-scikit-learn"
  "${MINGW_PACKAGE_PREFIX}-python-scipy"
  "${MINGW_PACKAGE_PREFIX}-python-numba"
  "${MINGW_PACKAGE_PREFIX}-python-llvmlite"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
)
source=("${_pyname}-${pkgver}.tar.gz::https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('a7c552569bf604a101fd54bba1d27c12389e065945dee3a6777a518c63a46f2b')

prepare() {
  rm -rf "python-build-${MSYSTEM}" | true
  cp -r "${_pyname//_/-}-$pkgver" "python-build-${MSYSTEM}"
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
